package cc.orange.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import cc.orange.R;
import cc.orange.entity.BaseEntity;
import cc.orange.entity.BlockListEntity;
import cc.orange.utils.CircleImageView;


/**
 */

public class RecycleBInAdapter extends BaseQuickAdapter<BlockListEntity.Data, BaseViewHolder> {

    private ItemClickListener itemClickListener;
    public RecycleBInAdapter(@Nullable List<BlockListEntity.Data> data) {
        super(R.layout.item_recycerbin, data);
    }

    public void setItemClickListener(ItemClickListener itemClickListener){
        this.itemClickListener = itemClickListener;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, BlockListEntity.Data item) {
        CircleImageView item_recycl_img = helper.getView(R.id.item_recycl_img);
        TextView recyc_item_click1 = helper.getView(R.id.recyc_item_click1);
        recyc_item_click1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != itemClickListener){
                    itemClickListener.itemClickListenr(helper.getLayoutPosition());
                }
            }
        });

        helper.setText(R.id.item_recycbin_text1,item.getBlockUserName());
        helper.setText(R.id.item_recycbin_text2,TextUtils.isEmpty(item.getRemark()) ? "" : item.getRemark());

        RequestOptions qe = new RequestOptions();
        if(!TextUtils.isEmpty(item.getBlockUserHeadPhoto())) {
            qe.error(item.getBlockUserHeadPhoto().equals("img_1") ?
                    R.drawable.icon_login_img3 : R.drawable.icon_login_img4);
        }else{
            qe.error(R.drawable.icon_login_img3);
        }
        Glide.with(mContext).load(item.getBlockUserHeadPhoto()).apply(qe).into(item_recycl_img);
    }


    public interface ItemClickListener{
        void itemClickListenr(int position);
    }
}
